package com.ysc.IUDS;

import com.ysc.domain.Bill;
import com.ysc.utils.mybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.Scanner;

public class Bill_Information {

    public static void CheckBills(int Stid,int Cid){
        SqlSession sqlSession = mybatisUtils.getSqlSession();
        String SqlId = "com.ysc.Dao.BillDao.selectBill";
        Bill bill = new Bill();
        bill.setStid(Stid);
        bill.setCid(Cid);
        Bill bill1 = sqlSession.selectOne(SqlId,bill);
        System.out.println(bill1);
        sqlSession.close();
    }

    public static int InsertBill(int Stid,int Cid,int OncePrice){
        Scanner inner = new Scanner(System.in);
        SqlSession sqlSession = mybatisUtils.getSqlSession();
        String Sqlid = "com.ysc.Dao.BillDao.insertBill";

        Bill bill = new Bill();
        bill.setStid(Stid);
        bill.setCid(Cid);
        System.out.println("交款时间：（具体到分钟）");
        bill.setBtime(inner.next());
        System.out.println("缴款金额：（首次最少交5节课的费用）");
        int money = inner.nextInt();
        bill.setBill_Account(money);
        int Cnum = money/OncePrice;
        System.out.println("您本次缴款后还能在本班上"+Cnum+"次课");
        bill.setLastClassNum(Cnum);
        int Num = sqlSession.insert(Sqlid,bill);

        sqlSession.commit();
        sqlSession.close();
        System.out.println(Num+"个学生报名成功");
        return Num;
    }
}
